package cn.tedu.egweibo1.base.response;

import cn.tedu.egweibo1.base.statuscode.StatusCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class JsonResult {
    private Integer statuscode;
    private String message;
    private Object data;

    public JsonResult(StatusCode statusCode, Object data) {
        this.statuscode = statusCode.getStatuscode();
        this.message = statusCode.getMessage();
        this.data = data;
    }
    public JsonResult(StatusCode statusCode) {
        this.statuscode = statusCode.getStatuscode();
        this.message = statusCode.getMessage();
    }
    public static JsonResult ok(){
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }
    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }

}
